package com.peanut.baby.mvp.calendar.decorators;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.text.style.LineBackgroundSpan;

import com.peanut.devlibrary.util.SysUtil;

/**
 * Created by anonymouslystudio on 2017/9/1.
 */

public class DrawableSpan implements LineBackgroundSpan {

    private Bitmap drawBit;

    public DrawableSpan(Bitmap bitmap) {
        this.drawBit = bitmap;

    }

    @Override
    public void drawBackground(Canvas c, Paint p, int left, int right, int top, int baseline, int bottom, CharSequence text, int start, int end, int lnum) {
        c.drawBitmap(drawBit, left + ((right - left) - drawBit.getWidth()) / 2, baseline + SysUtil.dip2px(2), new Paint());
    }
}